﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace ImageRecognition2.Action
{
    /// <summary>
    /// 
    /// </summary>
    public class ActionSetBitmap : AbstractCommand
    {
        private PictureBox m_PictureBox = null;
        private BitmapDelegate m_Delegate = null;

        /// <summary>
        /// Initializes a new instance of the <see cref="ActionSetBitmap"/> class.
        /// </summary>
        /// <param name="_delegate">The _delegate.</param>
        public ActionSetBitmap(BitmapDelegate _delegate )
        {
            m_Delegate = _delegate;
        }

        /// <summary>
        /// Runs the specified sender.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        public override void Run(object sender, EventArgs e)
        {
            Bitmap bitmap = (Bitmap)m_Delegate.Invoke((Bitmap)MainFormSingleton.ActivePictureBox.BackgroundImage);

            m_PictureBox.BackgroundImage = bitmap;
        }
    }
}
